package service;

import Pojo.Apply;
import Pojo.Houselist;
import dao.ApplyMapper;
import dao.HouselistMapper;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
@Transactional
public class ApplyServiceImpl
  implements ApplyService
{

  @Autowired
  private ApplyMapper applyMapper;

  @Autowired
  private HouselistMapper houselistMapper;

  public void insertapply(Apply apply)
  {
    this.applyMapper.insertapply(apply);
  }

  public List<Apply> findapplylist()
    throws Exception
  {
    List apply = this.applyMapper.findapplylist();
    return apply;
  }

  public Apply findbyhouse_id(String house_id)
  {
    Apply apply = this.applyMapper.findbyhouse_id(house_id);
    return apply;
  }

  public void deletebyhouse_id(String house_id)
  {
    this.applyMapper.deletebyhouse_id(house_id);
  }

  public void refuseapply(Houselist houselist)
  {
    this.houselistMapper.updatestatus(houselist);
    this.applyMapper.deletebyhouse_id(houselist.getHouseid());
  }
}